<?php
class Logs_Logs{
	protected $logfile;
	protected $file;
	private $tryb;
	
	function __construct($file = null,$tryb='w+'){	
		$this->tryb = $tryb;	
		$this->logfile	= is_null($file) ? 'logs.log' : $file;	
	    if (!$this->file = fopen($this->logfile,$this->tryb)) {
            return false;
        }		
	}
	
	public function add($text,$tryb=null,$widthTime = false)
	{
		if(!is_null($tryb) && is_string($tryb)) $this->tryb =  $tryb;
        $timestamp = ($widthTime) ? strftime("%c").': ' : "";
        
        fputs ($this->file, $timestamp.$text);
        return true;
	}

	function __destruct(){
		fclose($this->file);
	}
}
?>